<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-for结合v-bin案例</title>
    <style>
        .active{
            color: red;
        }
    </style>
</head>
<body>
    <div id="app">
        <ul>
            <li v-for="movie,index in movies" :class="{active:index === currIndex}" @click="setRed(index)">{{movie}}</li>
        </ul>
    </div>

    <script src="../vue/vue.js"></script>
    <script>
        const app = new Vue({
            el:'#app',
            data:{
                movies:['海王','海上钢琴师','海尔兄弟','海撒'],
                currIndex:0
            },
            methods: {
                setRed(index){
                    this.currIndex = index;
                }
            },
        });
    </script>
</body>
</html>